import http from "@/utils/http";
/**
 * 加入购物车
 * @param data 请求体参数
 */
export const postMemberCartAPI = (data) => {
  return http({
    method: "POST",
    url: "/member/cart",
    data,
  });
};

/**
 * 获取购物车列表
 */
export const getMemberCartAPI = () => {
  return http({
    method: "GET",
    url: "/member/cart",
  });
};

// 删除购物车单品
export const deleteCartApi = (data) => http.delete("/member/cart", data);

export const changeCartApi = (skuId, data) =>
  http.put(`/member/cart/${skuId}`, data);

/**
 * 购物车全选/取消全选
 * @param data selected 是否选中
 */
export const putMemberCartSelectedAPI = (data) => {
  return http({
    method: "PUT",
    url: "/member/cart/selected",
    data,
  });
};

/**
 * 获取订单详情
 * @param id 订单id
 */
export const getMemberOrderByIdAPI = (id) => {
  return http({
    method: "GET",
    url: `/member/order/${id}`,
  });
};
